package com.zlll.winner.mapper.bbs;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zlll.winner.business.model.bbs.BbsUserActionLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zlll.winner.business.vo.bbs.BbsPostVo;
import com.zlll.winner.business.vo.bbs.BbsUserActionLogVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 论坛用户点赞转发操作记录表 Mapper 接口
 * </p>
 *
 * @author Walert
 * @since 2019-09-12
 */
public interface BbsUserActionLogMapper extends BaseMapper<BbsUserActionLog> {

    @Select(" select " +
            "   m1.*  " +
            " from lht_user t " +
            " left join bbs_post m2 on (t.id = m2.user_id and m2.is_del = 0) " +
            " left join bbs_user_comment m3 on(t.id = m3.user_id and m2.is_del = 0) " +
            " left join bbs_user_action_log m1 on ((m2.id = m1.biz_id and m1.biz_type =1) or (m3.id = m1.biz_id and m1.biz_type =2) and m1.is_del = 0) " +
            " where t.id = ${userId} " +
            " and m1.action_type in (1,3,4) " +
            " group by m1.id " +
            " order by m1.create_time desc")
    IPage<BbsUserActionLogVo> selectPageByCustomer(IPage<BbsUserActionLogVo> page, @Param("ew") Wrapper<BbsUserActionLogVo> queryWrapper, @Param("userId") Long userId);

}
